﻿using Basic.FlowApplication.Extend;
using Basic.FlowApplication.Interface;
using Basic.FlowApplication.Model.AuditLog;
using Basic.FlowRemoteModel;
using Basic.FlowRemoteModel.Application.Model;
using WeDonekRpc.Client.Attr;

namespace Basic.FlowApplication.AuditEvent
{
    /// <summary>
    /// 终审通过
    /// </summary>
    [IocName("Audit_4")]
    [ClassLifetimeAttr(ClassLifetimeType.SingleInstance)]
    internal class AuditCompleteEvent : IItemAuditEvent
    {
        public AfootAuditLogItem ItemAudit ( Model.AuditFlowBody flow, FlowAuditLogState log, AuditRes result )
        {
            AfootAuditLogItem item = log.LogItem.Find(a => a.Id == result.ItemId);
            item.CheckAuditItem(result);
            item.AuditState = FlowAuditItemStatus.终审通过;
            item.AuditOpinion = result.Opinion;
            item.SignFileId = result.SignFileId;
            log.ToVoidRunItem(flow, item.RootNodeId, item.Id);
            return item;
        }
    }
}
